package wordit.ea.stopfunctions;

import wordit.ea.Generation;
import wordit.ea.StopFunction;

public class MaximumGenerationsStopFunction implements StopFunction {

	private int maxGenerations;

	public MaximumGenerationsStopFunction(int i) {
		setMaximumGenerations(i);
	}

	@Override
	public boolean shouldStop(Generation generation) {
		return generation.getCurrGenNumber()>=maxGenerations;
	}

	public void setMaximumGenerations(int n) {
		if (n < 0)
			throw new IllegalArgumentException(
					"Maximum Generations must be >=0");
		
		maxGenerations = n;
	}

	public int getMaximumGenerations() {
		return maxGenerations;
	}

}
